<!DOCTYPE html>
<html>
<head>
    <title>查看</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
        // 获取地址栏参数
        let hosrId = document.location.toString().GetValue("hosrId");
        // 查询病人信息
        function queryInfo(){
            layer.load(0)
            $.ajax({
                type: "GET",
                // 1. url请求地址前加后端API地址origin
                url: origin + "/be-hospital/" + hosrId,
                data: {jwtToken:jwtToken},
                dataType: "json",
                // 2. 允许携带cookie跨域请求
                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true,
                success: function (data) {
                    layer.closeAll();
                    if(data.code == 200){
                        let hosRegister = data.obj.hosRegister;
                        let beHospital = data.obj.beHospital;
                        // 填充数据
                        $("#hosrName").text(hosRegister.hosrName);
                        $("#hosrIdcar").text(hosRegister.hosrIdcar);
                        $("#hosrMedical").text(hosRegister.hosrMedical);
                        $("#hosrPhone").text(hosRegister.hosrPhone);
                        // 是否自费：0自费 1免费
                        if(hosRegister.hosrSelfPrice == 0){
                            $("#hosrSelfPrice").text("是");
                        }else{
                            $("#hosrSelfPrice").text("否");
                        }
                        // 计算年龄
                        let year = parseInt(hosRegister.hosrIdcar.substr(6,4));
                        let month = parseInt(hosRegister.hosrIdcar.substr(10,2));
                        let day = parseInt(hosRegister.hosrIdcar.substr(12,2));
                        let nowYear = new Date().getFullYear();
                        let nowMoth = new Date().getMonth() + 1;
                        let nowDay = new Date().getDate();
                        if(nowMoth - month > 0){
                            // 年龄即年份相减
                            $("#hosrAge").text(nowYear - year);
                        }else if(nowMoth - month < 0){
                            // 年龄即年份相减再减一
                            $("#hosrAge").text(nowYear - year - 1);
                        }else if(nowDay - day >= 0){
                            // 月分相等, 日相等或更大, 即刚好满岁或不超出一个月 -> 年龄即年份相减
                            $("#hosrAge").text(nowYear - year);
                        }else{
                            // 今年生日没到 -> 年龄即年份相减再减一
                            $("#hosrAge").text(nowYear - year - 1);
                        }
                        // 计算性别 第17位奇数是男, 偶数是女
                        if( hosRegister.hosrIdcar.substr(16,1)%2 == 0 ){
                            $("#hosrSex").text("女");	// 女

                        }else{
                            $("#hosrSex").text("男");  // 男
                        }
                        // 初复诊：0初诊1复诊
                        if(hosRegister.hosrLookDoctor == 0){
                            $("#hosrLookDoctor").text("初诊");
                        }else{
                            $("#hosrLookDoctor").text("复诊");
                        }
                        $("#hosrWork").text(hosRegister.hosrWork);

                        $("#keshi").text(hosRegister.keshi);
                        $("#doctor").text(hosRegister.doctorName);
                        $("#behAntecedent").text(beHospital.behAntecedent + "元");
                        $("#behIllness").text(beHospital.behIllness);
                    }else{
                        layer.msg(data.msg, function(){});
                    }
                },
                complete : function(xhr, status) {
                    myComplete(xhr, status);
                }
            })
        }

        $(function () {
            // 查询病人信息
            queryInfo();
            $('#backid').click(function(){
                window.location.href="index.html?pageSize="+globalPageSize+"&pageNum="+globalPageNum;
            });
        });
    </script>
</head>
<body>
<form action="index.html" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td id="hosrName"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件类型</td>
        <td>身份证</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件号</td>
        <td id="hosrIdcar"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">社保号</td>
        <td id="hosrMedical"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">联系电话</td>
        <td id="hosrPhone"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">是否自费</td>
        <td id="hosrSelfPrice"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td id="hosrSex"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td id="hosrAge"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">职业</td>
        <td id="hosrWork"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">初复诊</td>
        <td id="hosrLookDoctor"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所挂科室</td>
        <td id="keshi"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">指定医生</td>
        <td id="doctor"></td>
    </tr>
	 <tr>
        <td width="10%" class="tableleft">押金余额</td>
        <td id="behAntecedent"></td>
    </tr>
	
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td id="behIllness"></td>
	</tr>
    <tr>
        <td colspan="2">
			<center>
				<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
</html>